var activeTimesArray = new Array();
var currentActiveTimesParametersStorer = new activeTimesObject();
$("#slider-range").slider({
				range: true,
				min: 0,
				max: 1439,
				values: [540, 1020],
				slide: slideTime
			});

			function slideTime(event, ui){
				var minutes0 = parseInt($("#slider-range").slider("values", 0) % 60);
				var hours0 = parseInt($("#slider-range").slider("values", 0) / 60 % 24);
				var minutes1 = parseInt($("#slider-range").slider("values", 1) % 60);
				var hours1 = parseInt($("#slider-range").slider("values", 1) / 60 % 24);
				$("#time").text(getTime(hours0, minutes0,true) + ' - ' + getTime(hours1, minutes1,true));
                               // $("#time").text(getGMTNumber(hours0, minutes0) + ' - ' + getGMTNumber(hours1, minutes1));
                            // return {'hours0':hours0,'minutes0':minutes0,'hours1':hours1,'minutes1':minutes1};
                        currentActiveTimesParametersStorer.initialize(hours0,minutes0,hours1,minutes1)
//currentActiveTimesParametersStorer.startHour = hours0;
			}
			function getTime(hours, minutes,gmtBool) {
				var time = '';
				minutes = minutes + "";
                                if (gmtBool == true)
                                    {
                                 if (hours < 12) {
					time = "AM";
				}
				else {
					time = "PM";
				}
				if (hours == 0) {
					hours = 12;
				}
				if (hours > 12) {
					hours = hours - 12;
				}
                                    }

				if (minutes.length == 1) {
					minutes = "0" + minutes;
				}
				return hours + ":" + minutes +" "+time;
			}

                        			
			
function activeTimesObject (hour0,min0,hour1,min1,eventN,eventDes,eventReq)
{
    this.startHour = hour0;
    this.startMin = min0;
    this.endHour = hour1;
    this.endMin = min1;
    this.eventName = eventN;
    this.eventDescription = eventDes;
    this.eventRequirements = eventReq
    var GMTStartTime;
    var GMTEndTime;
    
    this.initialize =function (hour0,min0,hour1,min1,eventN,eventDes,eventReq)
    {
      this.startHour =hour0;
      this.startMin = min0;
      this.endHour = hour1;
      this.endMin = min1;
      this.eventName = eventN;
    this.eventDescription = eventDes;
    this.eventRequirements = eventReq
    }
    

    function covertToGMTNumber(hours, minutes) {

				minutes = minutes + "";

				if (minutes.length == 1) {
					minutes = "0" + minutes;
				}
				return hours+minutes;
			}

                        this.checkTimeConflict = function (hour0,min0,hour1,min1)
                        {
                            var outsideStartTime = parseInt(covertToGMTNumber(hour0,min0));
                            var outsideEndTime = parseInt(covertToGMTNumber(hour1,min1));
                            var internalStartTime = parseInt(covertToGMTNumber(this.startHour,this.startMin));
                            var internalEndTime = parseInt(covertToGMTNumber(this.endHour,this.endMin));

                            if ((outsideStartTime >= internalStartTime && outsideStartTime  <= internalEndTime) || (outsideEndTime >= internalStartTime && outsideEndTime  <= internalEndTime) )
                                {
                                    return false;
                                }
                                else
                                    {
                                        return true;
                                    }


                        }


                        this.listSetTime =function(array_index)
                        {
                         //getTime(this.startHour, this.startMin,true) + ' - ' + getTime(this.endHour, this.endMin,true);
                     var timeItem = "<div id='time_span_"+array_index+"'>"+
                         getTime(this.startHour, this.startMin,true)+' - '+getTime(this.endHour, this.endMin,true)+"  -  "+ this.eventDescription +"  -   <button id='time_span_button_"+array_index+"' title="+array_index+" class='deleteTimeSpanButton'>Delete</button> </div>";


//        jQuery("#setServiceTimesDiv").children().css("border", "1px dashed red");
//        jQuery("#WYSIWYGForm").children().each(function (index, domEle)
//        {
//            var domFormElementIDs = jQuery(domEle).attr("id");
//            jQuery(domEle).prepend('<span id="'+domFormElementIDs+'" class="deleteSpan"><span style="clear:both; float:right;" class="ui-icon ui-icon-scissors"></span><br></span>');
//        });
//
    
        return timeItem;
                        }

}